<template>
  <div class="header-info">
    <div class="icons">
      <span @click="settings">
        <el-icon><Setting /></el-icon>
      </span>
      <span @click="fullScreen">
        <el-icon><FullScreen /></el-icon>
      </span>
      <span @click="refreshPage">
        <el-icon><Refresh /></el-icon>
      </span>
    </div>
    <div class="userImg">
      <el-dropdown>
        <div class="el-dropdown">
          <img src="@/assets/img/90777712_p0_master1200.jpg" alt="" />
          <span>{{ name }}</span>
        </div>
        <template #dropdown>
          <div class="el-icons">
            <el-dropdown-menu>
              <el-dropdown-item @click="exitLoginClick">
                <el-icon size="15"><RemoveFilled /></el-icon>
                <span>退出系统</span>
              </el-dropdown-item>
              <el-dropdown-item divided>
                <el-icon size="15"><InfoFilled /></el-icon>
                <span>个人信息</span>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-icon size="15"><Lock /></el-icon>
                <span>修改密码</span>
              </el-dropdown-item>
              <!-- <el-dropdown-item>退出系统</el-dropdown-item>
            <el-dropdown-item disabled>Action 4</el-dropdown-item>
            <el-dropdown-item divided>Action 5</el-dropdown-item> -->
            </el-dropdown-menu>
          </div>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup lang="ts">
import { TOKEN } from '@/global/storage'
import { localCache } from '@/utils/Cache'
import { useRouter } from 'vue-router'
import useLoginStore from '@/store/modules/login'
import mittBus from '@/utils/mittBus'
const loginStore = useLoginStore()
const name = loginStore.userInfo.name

const router = useRouter()
function exitLoginClick() {
  // 清除token
  localCache.removeCache(TOKEN)
  // 跳转回登录页
  router.push('/login')
}
// 系统设置颜色
const settings = () => {
  mittBus.emit('openDrawer', true)
}
// 全屏
const fullScreen = () => {
  document.documentElement.requestFullscreen()
}
// 刷新页面
const refreshPage = () => {
  mittBus.emit('refreshPage')
}
</script>

<style lang="less" scoped>
.header-info {
  display: flex;
  align-items: center;
  .icons {
    display: flex;
    align-items: center;
    margin-right: 10px;
    span {
      font-size: 20px;
      text-align: center;
      line-height: 46px;
      width: 40px;
      height: 40px;
      display: block;
      margin-right: 15px;
      border-radius: 50%;
      border: 1px solid var(--el-border-color);
    }
  }
}
.el-dropdown {
  :focus {
    outline: 0;
  }
  display: flex;
  align-items: center;
  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  span {
    font-size: 16px;
    margin-left: 5px;
  }
}

.el-icons {
  span {
    font-size: 12px;
  }
}
</style>
